package com.example.jurisdiction.Controller;
import java.util.List;

import com.example.jurisdiction.Service.roleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import entity.role;

@CrossOrigin(methods= {RequestMethod.POST,RequestMethod.GET})
@Controller
@RequestMapping("/role")
public class roleController {
    @Autowired
    private roleService role;

    @RequestMapping("/list.do")
    public @ResponseBody List<role>list() throws Exception{
        return this.role.getRole();
    }


    //	添加用户
    @ResponseBody
    @RequestMapping("/addUser.do")
    public int add(@RequestBody role r) throws Exception {
        System.out.println(r.getRole_name());
        return this.role.addRole(r);
    }
    //	删除用户
    @ResponseBody
    @RequestMapping("/delUser.do")
    public int del(Integer id) throws Exception {

        return this.role.delRole(id);
    }
    //根据编号获取指定用户
    @RequestMapping("/getUser.do")
    public @ResponseBody role get(Integer id) throws Exception{
        return this.role.getRoles(id);
    }
    //	修改用户
    @ResponseBody
    @RequestMapping("/updateUser.do")
    public int updateUser(@RequestBody role r)throws Exception{
        return this.role.updateRole(r);

    }
}

